package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 环节办理人
 * @author 代码创建
 */
public class FlowStepApprover extends AbstractTableBean {

	private String StepId; //环节ID
	private String FlowId; //流程ID
	private int ApproverType; //办理人类型
	private String RoleOrPerson; //3.角色组合选择
	private boolean PreHandlerSw; //5.环节审批人开关
	private String PreHandler; //5.环节审批人
	private boolean DeptLeaderSw; //6.组织架构开关
	private int DeptLeaderTy; //组织架构1
	private int DeptLeader; //组织架构2
	private String ApproverFunc; //8.办理函数
	private int ApproverFuncTy; //办理函数1
	private int ApproverFuncOrg; //办理函数2
	private String NotesFormular; //9.公式计算
	private String HSway; //会审策略
	private int HSnum; //指定通过数量
	private String KeyUser; //关键办理人

	public static String TABLE_NAME = "Flow_StepApprover";
	public static String TABLEKEY_NAME = "StepId";
	public FlowStepApprover (IntegrateSql f){
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
	}

	public FlowStepApprover (IntegrateSql f,ResultSet rs) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		this.initParamToRs(rs);
	}

	public FlowStepApprover (IntegrateSql f,String keyValue) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		setCodePrepare(selectCodeById().toString());
		prepareSql.setPstValue(1, keyValue);
		ResultSet rs = executeQuery();
		if(rs.next()){
			initParamToRs(rs);
		}else{
			initParam();
		}
		rs.close();
	}

	@Override
	protected void initParam() {
		StepId = ""; //环节ID
		FlowId = ""; //流程ID
		ApproverType = 0; //办理人类型
		RoleOrPerson = ""; //3.角色组合选择
		PreHandlerSw = false; //5.环节审批人开关
		PreHandler = ""; //5.环节审批人
		DeptLeaderSw = false; //6.组织架构开关
		DeptLeaderTy = 0; //组织架构1
		DeptLeader = 0; //组织架构2
		ApproverFunc = ""; //8.办理函数
		ApproverFuncTy = 0; //办理函数1
		ApproverFuncOrg = 0; //办理函数2
		NotesFormular = ""; //9.公式计算
		HSway = ""; //会审策略
		HSnum = 0; //指定通过数量
		KeyUser = ""; //关键办理人
	}


	public void initParamToRs(ResultSet rs) throws SQLException{
		StepId = rs.getString("StepId"); //环节ID
		FlowId = rs.getString("FlowId"); //流程ID
		ApproverType = rs.getInt("ApproverType"); //办理人类型
		RoleOrPerson = rs.getString("RoleOrPerson"); //3.角色组合选择
		PreHandlerSw = rs.getInt("PreHandlerSw")==1?true:false; //5.环节审批人开关
		PreHandler = rs.getString("PreHandler"); //5.环节审批人
		DeptLeaderSw = rs.getInt("DeptLeaderSw")==1?true:false; //6.组织架构开关
		DeptLeaderTy = rs.getInt("DeptLeaderTy"); //组织架构1
		DeptLeader = rs.getInt("DeptLeader"); //组织架构2
		ApproverFunc = rs.getString("ApproverFunc"); //8.办理函数
		ApproverFuncTy = rs.getInt("ApproverFuncTy"); //办理函数1
		ApproverFuncOrg = rs.getInt("ApproverFuncOrg"); //办理函数2
		NotesFormular = rs.getString("NotesFormular"); //9.公式计算
		HSway = rs.getString("HSway"); //会审策略
		HSnum = rs.getInt("HSnum"); //指定通过数量
		KeyUser = rs.getString("KeyUser"); //关键办理人
		this.setKeyId(rs.getString("StepId"));
	}


	@Override
	protected int appendData() throws SQLException {
		int i = 1;
		prepareSql.setPstValue(i++,StepId); //环节ID
		prepareSql.setPstValue(i++,FlowId); //流程ID
		prepareSql.setPstValue(i++,ApproverType); //办理人类型
		prepareSql.setPstValue(i++,RoleOrPerson); //3.角色组合选择
		prepareSql.setPstValue(i++,PreHandlerSw?1:0); //5.环节审批人开关
		prepareSql.setPstValue(i++,PreHandler); //5.环节审批人
		prepareSql.setPstValue(i++,DeptLeaderSw?1:0); //6.组织架构开关
		prepareSql.setPstValue(i++,DeptLeaderTy); //组织架构1
		prepareSql.setPstValue(i++,DeptLeader); //组织架构2
		prepareSql.setPstValue(i++,ApproverFunc); //8.办理函数
		prepareSql.setPstValue(i++,ApproverFuncTy); //办理函数1
		prepareSql.setPstValue(i++,ApproverFuncOrg); //办理函数2
		prepareSql.setPstValue(i++,NotesFormular); //9.公式计算
		prepareSql.setPstValue(i++,HSway); //会审策略
		prepareSql.setPstValue(i++,HSnum); //指定通过数量
		prepareSql.setPstValue(i++,KeyUser); //关键办理人
		return i;
	}


	@Override
	public Vector<String> getFields() {
		Vector<String> vec = new Vector<String>();
		vec.addElement("StepId"); //环节ID
		vec.addElement("FlowId"); //流程ID
		vec.addElement("ApproverType"); //办理人类型
		vec.addElement("RoleOrPerson"); //3.角色组合选择
		vec.addElement("PreHandlerSw"); //5.环节审批人开关
		vec.addElement("PreHandler"); //5.环节审批人
		vec.addElement("DeptLeaderSw"); //6.组织架构开关
		vec.addElement("DeptLeaderTy"); //组织架构1
		vec.addElement("DeptLeader"); //组织架构2
		vec.addElement("ApproverFunc"); //8.办理函数
		vec.addElement("ApproverFuncTy"); //办理函数1
		vec.addElement("ApproverFuncOrg"); //办理函数2
		vec.addElement("NotesFormular"); //9.公式计算
		vec.addElement("HSway"); //会审策略
		vec.addElement("HSnum"); //指定通过数量
		vec.addElement("KeyUser"); //关键办理人
		return vec;
	}


	/**
	 * 设置环节ID
	 * @param stepid
	 */
	public void setStepId(String stepid){
		StepId = stepid;
	}
	/**
	 * 获取StepId
	 * @return 环节ID
	 */
	public String getStepId(){
		return StepId;
	}

	/**
	 * 设置流程ID
	 * @param flowid
	 */
	public void setFlowId(String flowid){
		FlowId = flowid;
	}
	/**
	 * 获取FlowId
	 * @return 流程ID
	 */
	public String getFlowId(){
		return FlowId;
	}

	/**
	 * 设置办理人类型
	 * @param approvertype
	 */
	public void setApproverType(int approvertype){
		ApproverType = approvertype;
	}
	/**
	 * 获取ApproverType
	 * @return 办理人类型
	 */
	public int getApproverType(){
		return ApproverType;
	}

	/**
	 * 设置3.角色组合选择
	 * @param roleorperson
	 */
	public void setRoleOrPerson(String roleorperson){
		RoleOrPerson = roleorperson;
	}
	/**
	 * 获取RoleOrPerson
	 * @return 3.角色组合选择
	 */
	public String getRoleOrPerson(){
		return RoleOrPerson;
	}

	/**
	 * 设置5.环节审批人开关
	 * @param prehandlersw
	 */
	public void setPreHandlerSw(boolean prehandlersw){
		PreHandlerSw = prehandlersw;
	}
	/**
	 * 获取PreHandlerSw
	 * @return 5.环节审批人开关
	 */
	public boolean getPreHandlerSw(){
		return PreHandlerSw;
	}

	/**
	 * 设置5.环节审批人
	 * @param prehandler
	 */
	public void setPreHandler(String prehandler){
		PreHandler = prehandler;
	}
	/**
	 * 获取PreHandler
	 * @return 5.环节审批人
	 */
	public String getPreHandler(){
		return PreHandler;
	}

	/**
	 * 设置6.组织架构开关
	 * @param deptleadersw
	 */
	public void setDeptLeaderSw(boolean deptleadersw){
		DeptLeaderSw = deptleadersw;
	}
	/**
	 * 获取DeptLeaderSw
	 * @return 6.组织架构开关
	 */
	public boolean getDeptLeaderSw(){
		return DeptLeaderSw;
	}

	/**
	 * 设置组织架构1
	 * @param deptleaderty
	 */
	public void setDeptLeaderTy(int deptleaderty){
		DeptLeaderTy = deptleaderty;
	}
	/**
	 * 获取DeptLeaderTy
	 * @return 组织架构1
	 */
	public int getDeptLeaderTy(){
		return DeptLeaderTy;
	}

	/**
	 * 设置组织架构2
	 * @param deptleader
	 */
	public void setDeptLeader(int deptleader){
		DeptLeader = deptleader;
	}
	/**
	 * 获取DeptLeader
	 * @return 组织架构2
	 */
	public int getDeptLeader(){
		return DeptLeader;
	}

	/**
	 * 设置8.办理函数
	 * @param approverfunc
	 */
	public void setApproverFunc(String approverfunc){
		ApproverFunc = approverfunc;
	}
	/**
	 * 获取ApproverFunc
	 * @return 8.办理函数
	 */
	public String getApproverFunc(){
		return ApproverFunc;
	}

	/**
	 * 设置办理函数1
	 * @param approverfuncty
	 */
	public void setApproverFuncTy(int approverfuncty){
		ApproverFuncTy = approverfuncty;
	}
	/**
	 * 获取ApproverFuncTy
	 * @return 办理函数1
	 */
	public int getApproverFuncTy(){
		return ApproverFuncTy;
	}

	/**
	 * 设置办理函数2
	 * @param approverfuncorg
	 */
	public void setApproverFuncOrg(int approverfuncorg){
		ApproverFuncOrg = approverfuncorg;
	}
	/**
	 * 获取ApproverFuncOrg
	 * @return 办理函数2
	 */
	public int getApproverFuncOrg(){
		return ApproverFuncOrg;
	}

	/**
	 * 设置9.公式计算
	 * @param notesformular
	 */
	public void setNotesFormular(String notesformular){
		NotesFormular = notesformular;
	}
	/**
	 * 获取NotesFormular
	 * @return 9.公式计算
	 */
	public String getNotesFormular(){
		return NotesFormular;
	}

	/**
	 * 设置会审策略
	 * @param hsway
	 */
	public void setHSway(String hsway){
		HSway = hsway;
	}
	/**
	 * 获取HSway
	 * @return 会审策略
	 */
	public String getHSway(){
		return HSway;
	}

	/**
	 * 设置指定通过数量
	 * @param hsnum
	 */
	public void setHSnum(int hsnum){
		HSnum = hsnum;
	}
	/**
	 * 获取HSnum
	 * @return 指定通过数量
	 */
	public int getHSnum(){
		return HSnum;
	}

	/**
	 * 设置关键办理人
	 * @param keyuser
	 */
	public void setKeyUser(String keyuser){
		KeyUser = keyuser;
	}
	/**
	 * 获取KeyUser
	 * @return 关键办理人
	 */
	public String getKeyUser(){
		return KeyUser;
	}

}
